package com.yyf.springboot2.controller;

import com.alibaba.fastjson.JSONObject;
import com.yyf.springboot2.address.Area;
import com.yyf.springboot2.address.City;
import com.yyf.springboot2.address.Province;
import com.yyf.springboot2.common.ResultBean;
import com.yyf.springboot2.service.AddressService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yyf
 * @since 2019-05-29
 */
@Controller
@RequestMapping("/tAddress")
public class TAddressController {

//    @Resource
//    private AddressService addressService;
//    @GetMapping("/province")
//    @ResponseBody
//    public ResultBean provinces(){
//        List<Province> provinces = addressService.getProvinces();
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("provinces",provinces);
//        JSONObject jsonObject = new JSONObject(map);
//        return ResultBean.build(200,"成功",jsonObject);
//    }

//    @RequestMapping(value="address/city",method=RequestMethod.POST)
//    @ResponseBody
//    public ResultBean cities(@RequestParam("province")Integer province){
//        Map<String, Object> map = new HashMap<String, Object>();
//        List<City> cities = new ArrayList<City>();
//        if(province != null){
//            cities = addressService.getCities(province);
//        }
//        map.put("cities", cities);
//        JSONObject jsonObject = new JSONObject(map);
//        return ResultBean.build(200,"成功",jsonObject);
//    }
//    @RequestMapping(value="address/county",method=RequestMethod.POST)
//    @ResponseBody
//    public ResultBean counties(@RequestParam("city")Integer city){
//        Map<String, Object> map = new HashMap<String, Object>();
//        List<Area> counties = new ArrayList<Area>();
//        if(city != null){
//            counties = addressService.getCounties(city);
//        }
//        map.put("counties", counties);
//        JSONObject jsonObject = new JSONObject(map);
//        return ResultBean.build(200,"成功",jsonObject);
//    }

}
